-
Notifications
You must be signed in to change notification settings - Fork 289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(server): Fix flakiness in TestServer_ReloadWorkerTags #3810
Conversation
This attempts to address some flakiness by replacing hard-coded sleeps with some smarter polling similarly used in TestServer_ReloadInitialUpstreams.
require.True(ok) | ||
tags := w.CanonicalTags() | ||
v, ok := tags[key] | ||
require.True(ok, fmt.Sprintf("EXPECTED: map[%s:%s], ACTUAL: %+v", key, values, tags)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated logging to get more information
timeout := time.NewTimer(15 * time.Second) | ||
poll := time.NewTimer(0) | ||
var w *server.Worker | ||
var lastStatusTime time.Time | ||
serversRepo, err := testController.Controller().ServersRepoFn() | ||
require.NoError(err) | ||
pollController: | ||
for { | ||
select { | ||
case <-timeout.C: | ||
t.Fatalf("timeout waiting for worker to connect to controller") | ||
case <-poll.C: | ||
w, err = serversRepo.LookupWorkerByName(testController.Context(), "test") | ||
require.NoError(err) | ||
if w != nil { | ||
switch { | ||
case lastStatusTime.IsZero(): | ||
lastStatusTime = w.GetLastStatusTime().AsTime().Round(time.Second) | ||
default: | ||
if !lastStatusTime.Equal(w.GetLastStatusTime().AsTime().Round(time.Second)) { | ||
timeout.Stop() | ||
break pollController | ||
} | ||
} | ||
} | ||
poll.Reset(time.Second) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from TestServer_ReloadInitialUpstreams
timeout.Reset(15 * time.Second) | ||
poll.Reset(time.Second) | ||
lastStatusTime = time.Time{} | ||
startTime := time.Now() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a slightly modified version of the loop. TestServer_ReloadInitialUpstreams
is different in that it uses a second controller and can set lastStatusTime
to zero. In this case, the idea is to wait for 2 status updates starting from this point in time.
Just got a failure when testing this locally... back to the drawing board... |
Looks like there might be actually something in the boundary application causing this. More investigation is needed. Closing this PR. |
This PR attempts to address flakiness in
TestServer_ReloadWorkerTags
by replacing hard-coded sleeps with some smarter polling similarly used inTestServer_ReloadInitialUpstreams
. This test would occasionally fail for the following reason...The test is expecting the controller to get updated worker tags, but sometimes, it's not getting the expected values. The initial theory is that the hard-coded sleeps didn't wait long enough for the changes to propagate to the controller.